package org.campuscontent.io;

import java.io.File;
import java.util.Vector;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.LineIterator;

public class Filter
{
    public Filter()
    {
        keys = new Vector<String>( 10, 5 );
        keys.add( "Loaded com.jgraph" );
    } 
    
    public void load( String filename )
    {
        try
        {
            LineIterator itLog = FileUtils.lineIterator( new File( filename ) );
            
            Vector<String> content = new Vector<String>( 10, 5 );
            while ( itLog.hasNext() )
            {
                String curr = itLog.nextLine().trim();
                if ( curr != null && !curr.equals( "" ) )
                {
                    for ( String k : keys )
                    {
                        if ( curr.contains( k ) )
                            content.add( curr );
                    }
                }
            }
            
            for ( String it : content )
            {
                System.out.println( it );
            }
        }
        catch ( Exception e )
        {
            e.printStackTrace();
        }
    
    }
    
    public static void main( String[] args )
    {
        String filename = "C:\\Dokumente und Einstellungen\\rojas\\Desktop\\jgraphlayout\\jgraphlayout-demo\\content.txt";
        Filter f = new Filter();
        f.load( filename );
    }
    
    protected Vector<String> keys;
}
